package com.cskaoyan.gateway.controller.shopping;

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.shopping.IProductService;
import com.mall.shopping.constants.ShoppingRetCode;
import com.mall.shopping.dto.RecommendResponse;
import com.mall.user.annotation.Anoymous;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @author 岳子昂
 * @date 2022-01-20 20:22
 * @version 1.0
 */
@Slf4j
@RestController
@RequestMapping("shopping")
public class RecommendController {

    @Reference(timeout = 10000,retries = 2, check = false)
    IProductService iProductService;

    /**
     * @description:
     * @param:
     * @return:
     * @author 岳子昂
     * @date: 2022-01-20 20:23
     */
    @RequestMapping("recommend")
    @Anoymous
    public ResponseData recommend(){
        // 调用service方法
        RecommendResponse response = iProductService.getRecommendGoods();

        // 判断传回来的结果
        if (response.getCode().equals(ShoppingRetCode.SUCCESS.getCode())){
            return new ResponseUtil().setData(response.getPanelContentItemDtos());
        }
        return new ResponseUtil().setErrorMsg(response.getMsg());
    }
}
